package cn.chl.service.impl;

import cn.chl.domain.Floor;
import cn.chl.mapper.FloorMapper;
import cn.chl.service.IFloorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class FloorServiceImpl implements IFloorService {

    @Autowired
    private FloorMapper floorMapper;

    /**
     * 查询单个对象
     */
    @Override
    public Floor getOne(Integer id) {
        return floorMapper.getOne(id);
    }

    /**
     * 添加数据
     */
    @Override
    public void add(Floor floor) {
        if (floor.getName() == null){
            throw new RuntimeException("楼层名不能为空！");
        }
        if (floor.getBuildId() == null){
            throw new RuntimeException("楼栋不能为空！");
        }

        floorMapper.add(floor);
    }
}
